import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:shop/model/MyModelNotifier.dart';
import 'package:shop/provider/provider_widget.dart';
import 'package:shop/test/MyModelScreen.dart';


class NotifierProviderScreen extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _NotifierProviderScreen();
  }
}

class _NotifierProviderScreen extends State<NotifierProviderScreen> {

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("provider"),
      ),

      body: Column(
        crossAxisAlignment: CrossAxisAlignment.center,
        children: <Widget>[
          ProviderWidget<MyModelNotifier>(
              builder: (context, model, child){
                return Center(
                  child: Column(
                    children: <Widget>[
                      Text("${model.count}"),

                      Padding(
                        padding: const EdgeInsets.all(8.0),
                        child: FlatButton(
                          color: Colors.tealAccent,
                          onPressed: ()=>model.increment(),
                          child: Icon(Icons.add),
                        ),
                      ),

                      ButtonTheme(
                        minWidth: 200.0,
                        height: 50.0,
                        //RaisedButton悬浮按钮
                        child: RaisedButton(
                          //按钮的阴影
                            elevation: 2.0,
                            //按下时的阴影
                            highlightElevation: 8.0,
                            //禁用时的阴影
                            disabledElevation: 0.0,
                            child: Text(("跳转到MyModelScreen页面")),
                            //按钮颜色
                            color: Colors.blue,
                            //按下时的按钮颜色
                            highlightColor: Colors.blue[700],
                            onPressed: () {
                              Navigator.push(
                                  context,
                                  MaterialPageRoute(
                                      builder: (context) => MyModelScreen()));
                            }),
                      ),
                    ],
                  ),
                );
              },
              model: MyModelNotifier(),
          ),
        ],
      ));
  }

}


